<template>
  <a-card :bordered="false">
    <!-- table区域-begin -->
    <div>
      <vxe-grid
        style="width: 100%;"
        :height="curHeight"
        size="mini"
        align="center"
        highlight-hover-row
        stripe
        row-key
        row-id="selectedRowKeys"
        column-min-width="150"
        id="id"
        keep-source
        :loading="loading"
        border
        resizable
        auto-resize
        showOverflow
        showHeaderOverflow
        :pager-config="tablePage"
        ref="xGrid"
        :row-config="{ useKey: true,keyField: 'id',isCurrent:true,isHover:true}"
        :checkbox-config="{
          checkRowKeys:selectedRowKeys,
          trigger: 'row',
          highlight: true,
          reserve: true}"
        @sort-change="sortChange"
        @checkbox-change="checkboxChangeEvent"
        @checkbox-all="checkboxChangeEvent"
        :data="dataSource"
        :columns="columns"
        @page-change="handlePageChange"
      >
        <template v-slot:top>
          <div class="table-operator">
            <a-button type="primary" icon="plus" @click="handleAdd">新增</a-button>
            <!-- 高级查询区域 -->
            <j-super-query :fieldList="superFieldList" ref="superQueryModal"
                           @handleSuperQuery="handleSuperQuery"></j-super-query>
            <a-dropdown v-if="selectedRowKeys.length > 0">
              <a-menu slot="overlay">
                <a-menu-item key="1" @click="batchDel">
                  <a-icon type="delete"/>
                  删除
                </a-menu-item>
              </a-menu>
              <a-button type="primary" icon="down">批量操作</a-button>
            </a-dropdown>
          </div>
        </template>
        <template v-slot:operate="{ row }">
          <a-button v-if="row.status == 0" type="primary" shape="circle" @click="handleEdit(row)" icon="edit"/>
          <a-button v-else type="primary" shape="circle" @click="handleEdit(row)" icon="edit" disabled/>
          <a-divider type="vertical"/>
          <a-dropdown>
            <a-button type="primary" shape="circle" class="ant-dropdown-link" icon="setting"/>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(row)">详情</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </template>
        <template v-slot:empty>
          <a-empty/>
        </template>
      </vxe-grid>
    </div>
    <!-- table区域-end -->
    <wcs-pallet-task-modal ref="modalForm" @ok="modalFormOk"></wcs-pallet-task-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { HYListMixin } from '@/mixins/HYListMixin'
  import WcsPalletTaskModal from './modules/WcsPalletTaskModal'

  export default {
    name: 'WcsPalletTaskList',
    mixins:[HYListMixin, mixinDevice],
    components: {
      WcsPalletTaskModal
    },
    data () {
      return {
        description: '拆叠盘任务管理页面',
        // 表头
        columns: [
          {type: "checkbox", width: 50, align: "center"},//多选
          {type: "seq", width: 50, align: "center"},//
          { title : '点位', align : "center", field : 'coord' },
          { title : '托盘号', align : "center", field : 'palletNo' },
          { title : '任务类型', align : "center", field : 'taskType' },
          { title : '任务状态', align : "center", field : 'taskStatus' },
          { title : 'plc编号', align : "center", field : 'plcNo' },
          { title : '备注', align : "center", field : 'remark' },
          {title: '操作', fixed: 'right', width: 105, slots: {default: 'operate'}}
        ],
        url: {
          list: "/wcs/wcsPalletTask/list",
          delete: "/wcs/wcsPalletTask/delete",
          deleteBatch: "/wcs/wcsPalletTask/deleteBatch",
          exportXlsUrl: "/wcs/wcsPalletTask/exportXls",
          importExcelUrl: "wcs/wcsPalletTask/importExcel",
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'coord',text:'点位',dictCode:''})
        fieldList.push({type:'string',value:'palletNo',text:'托盘号',dictCode:''})
        fieldList.push({type:'int',value:'taskType',text:'任务类型',dictCode:''})
        fieldList.push({type:'int',value:'taskStatus',text:'任务状态',dictCode:''})
        fieldList.push({type:'string',value:'plcNo',text:'plc编号',dictCode:''})
        fieldList.push({type:'string',value:'remark',text:'备注',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>